package com.tencent.sr.iris.basic.mp.dependency;

import com.alibaba.fastjson.JSON;
import com.tencent.sr.iris.basic.mp.common.util.HttpUtils;
import com.tencent.sr.iris.basic.service.interfaces.client.NoticeClient;
import com.tencent.sr.iris.basic.service.interfaces.request.NoticeListRequest;
import com.tencent.sr.iris.basic.service.interfaces.response.NoticeListResponse;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.springbootstarter.authtoken.localbean.AppUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Component
public class NoticeDependency {

    @Resource
    private NoticeClient noticeClient;

    @Resource
    private AppUser appUser;

    public Boolean hasNew(NoticeListRequest request) {
        request.setUid(appUser.getUid());
        log.info("NoticeDependency.hasNew调用，入参：{}", JSON.toJSONString(request));
        HttpResult<Boolean> result = noticeClient.hasNew(request);
        return HttpUtils.handleError(result);
    }

    public List<NoticeListResponse> validNoticeList(NoticeListRequest request) {
        request.setUid(appUser.getUid());
        log.info("NoticeDependency.validNoticeList调用，入参：{}", JSON.toJSONString(request));
        HttpResult<List<NoticeListResponse>> result = noticeClient.validNoticeList(request);
        return HttpUtils.handleError(result);
    }
}
